<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!doctype html>
<html  class="x-admin-sm">
<head>
	<meta charset="UTF-8">
	<title>管理登录</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/login.css">
	<link rel="stylesheet" href="./css/index.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>

</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">管理登录</div>
        <div id="darkbannerwrap"></div>
        
       <form method="post" class="layui-form" action="${pageContext.request.contextPath}/AdminServlet" enctype="application/x-www-form-urlencoded">
        	<input type="hidden" name="op" value="adminLogin">
            <input name="adminName" placeholder="管理员名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="adminPassword" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input type="checkbox" class="layui-input" name="remember" value="remember">记住密码
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>

	
	<!-- 引入jQuerycookie -->
	<script type="text/javascript"
		src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script>
        $(function  () {
            layui.use('form', function(){
              var form = layui.form;
              // layer.msg('玩命卖萌中', function(){
              //   //关闭后的操作
              //   });
              //监听提交
              form.on('submit(login)', function(data){
                // alert(888)
                layer.msg(JSON.stringify(data.field),function(){
                    location.href='index.html'
                });
                return false;
              });
            });
            
          //获取cookie
			let remember = $.cookie("remember");
			//判断cookie是否存在
			if (remember != null) {
				let vs = remember.split("=");
				//将cookie拆开后赋值到两个输入框
				$("input[name='adminName']").val(vs[0]);
				$("input[name='adminPassword']").val(vs[1]);
				$("input[name='remember']").prop("checked", true);
			}
			//当客户端访问登陆页面的时候，输入用户名失去焦点，如果手机号码
			//与cookie不匹配，则清空密码和记住密码
			$("input[name='adminName']").on("input", function() {
				//清除填充内容
				$("input[name='adminPassword']").val("");
				$("input[name='remember']").prop("checked", false);
				//对复选框中的样式做处理
				$(".layui-form-checkbox").removeClass("layui-form-checked");
				//判断是否存在remember
				let remember = $.cookie("remember");
				if(remember != null){
					//用输入的手机号和cookie所取的值比较
					let vs = remember.split("=");
					let inputPhoneNumber = $(this).val();
					if(inputPhoneNumber == vs[0]){
						//对密码框和复选框进行填值
						$("input[name='adminPassword']").val(vs[1]);
						$("input[name='remember']").prop("checked",true);
						//对复选框的打勾样式进行恢复
						$(".layui-form-checkbox").addClass("layui-form-checked");
					}
					
				}
				
				
			})
        })
    </script>
    <!-- 底部结束 -->
</body>
</html>